<template>
	<view class="bank">
		<view class="card" v-for="item in inList" :key="item.id" @click="up(item)">
			<view class="flex">
				<view class="">
					<view class="b_t">
						{{item.bank_branch}}
					</view>
					<view class="b_n">
						储蓄卡
					</view>
				</view>
			</view>
			<view class="b_d">
			</view>
			<view class="flex  felx-y-c flex-x-b">
				<view class="card_num">
					{{item.bank_card_number}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as Api from '@/api/recovery'
	export default {
		data() {
			return {
				inList: [],
				amount:''
			}
		},
		onLoad(options) {
			this.amount=options.amount
		},
		onShow() {
			this.getPageData()
		},
		methods: {
			bankCard() {
				uni.navigateTo({
					url: '/pages/bank/bind'
				})
			},
			getPageData(callback) {
				const app = this
				console.log(uni.getStorageSync('userId'))
				Api.bankList({
						user_id: uni.getStorageSync('userId')
					})
					.then(result => {
						console.log(result)
						this.inList = result.data.list
					})
					.finally(() => callback && callback())
			},
			
			up(m){
				const app = this
				app.cardInfo=m
				uni.showModal({
				  title: '友情提示',
				  content: '您确定要提现吗？',
				  showCancel: true,
				  success({ confirm }) {
				    // 确认删除
				    confirm && app.onClearCart()
				  }
				})
				
			},
			onClearCart(){
				const app = this
				return new Promise((resolve, reject) => {
				  Api.getMoney(
				  {
					  amount:this.amount,
					  card_id:this.cardInfo.id,
					  bank_card_number:this.cardInfo.bank_card_number
				  })
				    .then(result => {
						console.log(result)
						uni.switchTab({
							url:'/pages/user/index'
						})
				    })
				})
			}
			
		}
	}
</script>

<style>
	.bank {
		padding: 25rpx 32rpx;
	}

	.card {
		padding: 33rpx 39rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin-bottom: 24rpx;
	}

	.flex {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.image_1 {
		width: 65rpx;
		height: 67rpx;
	}

	.image_1 image {
		width: 100%;
		height: 100%;
	}

	.b_t {
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #000000;
		letter-spacing: 20rpx;
	}

	.b_n {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #000000;
		letter-spacing: 20rpx;
		margin-top: 20rpx;
	}

	.b_d {
		width: 30rpx;
		height: 9rpx;
		background: #FFB823;
		margin: 20rpx 0;
	}

	.card_num {
		font-size: 34rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #000000;
	}

	.btn {
		width: 686rpx;
		height: 88rpx;
		background: #66B347;
		border-radius: 44rpx;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		margin: 0 auto;
		text-align: center;
		line-height: 88rpx;
		margin-top: 100rpx;
	}

	.del_image {
		width: 30rpx;
		height: 30rpx;
	}

	.del_image image {
		width: 100%;
		height: 100%;
	}
</style>
